package array;

import java.util.HashMap;
import java.util.Map;

public class leetCode169_majorityElement {

    public int majorityElement(int[] nums) {
        if(nums == null || nums.length == 0) return 0;
        int a = nums[0];
        int count = 0;
        for (int num : nums) {
            if(count == 0){
                a = num;
            }
            count += a == num ? 1:-1;
        }
        return a;
    }
}
